//
//  MainFuncVM.swift
//  kxf
//
//  Created by Mac on 2024/3/9.
//

import Foundation
import UIKit

class MainFuncVM: UIView {
    
    let selfHeight = kFitWidth(160)

    override init(frame:CGRect){
        super.init(frame: CGRect.init(x: 0, y: frame.origin.y, width: SCREEN_WIDHT, height: selfHeight))
        self.backgroundColor = .white
        self.isUserInteractionEnabled = true
        self.layer.cornerRadius = kFitWidth(12)
        self.clipsToBounds = true
        
        initUI()
    }
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    lazy var titleLineView : UIView = {
        let vi = UIView()
        vi.backgroundColor = WHColor_16(colorStr: "EE3845")
        vi.layer.cornerRadius = kFitWidth(2)
        vi.clipsToBounds = true
        
        return vi
    }()
    lazy var titleLabel : UILabel = {
        let lab = UILabel()
        lab.textColor = WHColor_16(colorStr: "3D3B3B")
        lab.font = .systemFont(ofSize: 20, weight: .medium)
        lab.text = "展业中心"
        
        return lab
    }()
    lazy var funcOneVm : MainFuncItemVM = {
        let vm = MainFuncItemVM.init(frame: CGRect.init(x: kFitWidth(25), y: kFitWidth(56), width: 0, height: 0))
        vm.titleLabel.text = "商户进件"
        vm.imgView.setImgLocal(imgName: "main_func_authen_icon")
//        vm.backgroundColor = WHColor_16(colorStr: "F3F7FE")
        
        return vm
    }()
    lazy var funcTwoVm : MainFuncItemVM = {
        let vm = MainFuncItemVM.init(frame: CGRect.init(x: kFitWidth(142), y: kFitWidth(56), width: 0, height: 0))
        vm.titleLabel.text = "待处理报件"
        vm.imgView.setImgLocal(imgName: "main_func_daichuli_icon")
//        vm.backgroundColor = WHColor_16(colorStr: "E2F5E9")
        
        return vm
    }()
    lazy var funcThreeVm : MainFuncItemVM = {
        let vm = MainFuncItemVM.init(frame: CGRect.init(x: kFitWidth(259), y: kFitWidth(56), width: 0, height: 0))
        vm.titleLabel.text = "邀请"
        vm.imgView.setImgLocal(imgName: "main_func_invite_icon")
//        vm.backgroundColor = WHColor_16(colorStr: "E4E0FF")
        
        return vm
    }()
}

extension MainFuncVM{
    func initUI() {
        addSubview(titleLineView)
        addSubview(titleLabel)
        addSubview(funcOneVm)
        addSubview(funcTwoVm)
        addSubview(funcThreeVm)
        funcThreeVm.isHidden = true
        
        setConstrait()
    }
    func setConstrait() {
        titleLineView.snp.makeConstraints { make in
            make.left.equalTo(kFitWidth(24))
            make.top.equalTo(kFitWidth(22))
            make.width.equalTo(kFitWidth(4))
            make.height.equalTo(kFitWidth(20))
        }
        titleLabel.snp.makeConstraints { make in
            make.left.equalTo(titleLineView.snp.right).offset(kFitWidth(8))
            make.centerY.lessThanOrEqualTo(titleLineView)
        }
    }
    func updateUIForData() {
        funcThreeVm.isHidden = false
        titleLabel.text = "数据中心"
//        funcOneVm.backgroundColor = WHColor_16(colorStr: "FFE7D3")
//        funcTwoVm.backgroundColor = WHColor_16(colorStr: "FFEDEA")
//        funcThreeVm.backgroundColor = WHColor_16(colorStr: "F3F7FE")
        
        funcOneVm.titleLabel.text = "交易数据"
        funcTwoVm.titleLabel.text = "商户管理"
        funcThreeVm.titleLabel.text = "服务商管理"
        
        funcOneVm.imgView.setImgLocal(imgName: "main_func_data_icon")
        funcTwoVm.imgView.setImgLocal(imgName: "main_func_merc_manage_icon")
        funcThreeVm.imgView.setImgLocal(imgName: "main_func_fuwu_manage_icon")
    }
    func updateUIForWallet() {
        titleLabel.text = "钱包中心"
        funcOneVm.titleLabel.text = "钱包"
        
        funcOneVm.imgView.setImgLocal(imgName: "main_func_wallet_icon")
        funcTwoVm.isHidden = true
        funcThreeVm.isHidden = true
    }
}
